package com.nado.iims2.blog.dao.service;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.nado.extensions.sql.SimpleSqlMapDaoSupport;
import com.nado.iims2.blog.model.service.Namespace;

@Repository("NamespaceDAO")
public class NamespaceDAOImpl extends SimpleSqlMapDaoSupport implements NamespaceDAO {
	private final static String PREFIX = "com.nado.iims2.blog.nspace.";
	
	@Override
	public List<Namespace> selectNamespaceList(int offset, int count) throws SQLException {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("offset", offset);
		params.put("count", count);
		
		return getSqlMapClient().queryForList(PREFIX + "selectNamespaceList", params);
	}

	@Override
	public int selectNamespaceListCount() throws SQLException {
		return (Integer) getSqlMapClient().queryForObject(PREFIX + "selectNamespaceListCount");
	}

	@Override
	public int insertNamespace(Namespace model) throws SQLException {
		return getSqlMapClient().update(PREFIX + "insertNamespace", model);
	}

	@Override
	public int updateNamespace(Namespace model) throws SQLException {
		return getSqlMapClient().update(PREFIX + "updateNamespace", model);
	}

}
